composetable: Limit algorithmic checking
authorMatthias Clasen <mclasen@redhat.com>
Fri, 26 Mar 2021 23:48:41 +0000 (19:48 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 27 Mar 2021 00:27:55 +0000 (20:27 -0400)
Only check for combinations of up to 2 dead keys with
a base character. We don't want to spend ages generating
all permutations of long sequences.

gtk/gtkcomposetable.c

index fb5ab6abe6e2dd175e8c81cb391e6c2a591e5f2f..7aa9792e3bb7339d6079e7cb5d6311258385f5a3 100644 (file)
@@ -1190,6 +1190,12 @@ gtk_check_algorithmically (const guint16 *compose_buffer,
 
   for (i = 0; i < n_compose && IS_DEAD_KEY (compose_buffer[i]); i++)
     ;
+
+  /* Allow at most 2 dead keys */
+  if (i > 2)
+    return FALSE;
+
+  /* Can't combine if there's no base character */
   if (i == n_compose)
     return TRUE;